import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

@SpringBootTest
public class JedisDemo {

    @Test
    public void testJedisCluster(){
        Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
        jedisClusterNodes.add(new HostAndPort("106.13.48.251", 7001));
        jedisClusterNodes.add(new HostAndPort("106.13.48.251", 7002));
        jedisClusterNodes.add(new HostAndPort("106.13.48.251", 7003));
        jedisClusterNodes.add(new HostAndPort("106.13.48.251", 7004));
        jedisClusterNodes.add(new HostAndPort("106.13.48.251", 7005));
        jedisClusterNodes.add(new HostAndPort("106.13.48.251", 7006));
        jedisClusterNodes.add(new HostAndPort("106.13.48.251", 7007));
        jedisClusterNodes.add(new HostAndPort("106.13.48.251", 7008));
        JedisCluster jc = new JedisCluster(jedisClusterNodes);
        jc.set("cust:2:name", "andy");

        String value = jc.get("cust:2:name");
        System.out.println(value);
    }

    @Test
    public void testJedis(){
        Jedis jedis = new Jedis("106.13.48.251", 7002);
        jedis.set("cust:2:name", "andy");

        String value = jedis.get("cust:2:name");
        System.out.println(value);
    }

}
